import 'package:flutter/material.dart';
import 'package:flutter_dk_form/flutter_dk_form.dart';
/// 单行输入
class DkSingleInputFormField extends DkFormField<String> {
  DkSingleInputFormField({
    Key key,
    @required String attribute,
    String initialValue,
    String title='',
    ValueChanged<String> onChanged,
    DkFormFieldValidator<String> validator,
    ValueTransformer valueTransformer,
    String placeholder = '',
    int maxLength,
    bool hasLine = true,
    InputCharFormatterType inputCharFormatterType = InputCharFormatterType.InputCharFormatterNone,
  }) : super(
    attribute: attribute,
    initialValue: initialValue,
    validator: validator,
    valueTransformer: valueTransformer,
    builder: (DkFormFieldState<String> field) {
      final DkFormFieldState state = field;
      void onChangedHandler(String value) {
        if (onChanged != null) {
          onChanged(value);
        }
        field.didChange(value);
      }
      return SingleInputWidget(
        title: title,
        hintText: placeholder,
        initialValue: state.value,
        maxLength: maxLength,
        hasLine: hasLine,
        onChanged: onChangedHandler,
        inputCharFormatterType: inputCharFormatterType,
      );
    },
  );
}





